package com.liao.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.liao.dao.ComputerDao;
import com.liao.util.Result;

@RestController
public class ComputerController {
@Autowired
private ComputerDao computerDao;
@RequestMapping("/getAllComputer")
@ResponseBody
public Object getAllComputer(@RequestParam Map<String, Object> map) {
		 
	 Integer page = Integer.parseInt(map.get("page").toString());
	Integer limit = Integer.parseInt(map.get("limit").toString());
	
	map.put("page", (page - 1) * limit);
	map.put("limit", limit);
	List<Map<String, Object>>    Computer = computerDao.getAllComputer(map);

	int count = computerDao.getCount();// 获取总条数
	Result res = new Result("0", "true", count, Computer);
	return res;
}
@RequestMapping("/Computerinserts")
@ResponseBody
public Object Computerinserts(@RequestParam Map<String, Object> map) {
	 Result res =new Result("0","true",computerDao.Computerdinserts(map),"添加成功");
	 return res;    
}
@RequestMapping("/Computerupdate")
@ResponseBody
public Object Computerupdate(@RequestParam Map<String, Object> map) {
	 Result res =new Result("0","true",computerDao.Computerdupdate(map),"修改成功");
	 return res; 
}
@RequestMapping("/Computerel")
@ResponseBody
public Object Computerel(int cid) {
	 Result res =new Result("0","true",computerDao.Computerddeletes(cid),"删除成功");
	 return res; 
}
}
